// JiraStatus.js
// SyncTickets.js
// 
// 
class SyncTicketStatus
{
    constructor(options)
    {
        this.mapping = {};

        if (
            Object.keys(options).length
        ) {
            // only task can direct change to Done
            this.targetJira = new JiraClient(options);
        }
    }

    async syncTicketStatus(issueKeyOrId, finalStatus, type)
    {
        // Type is Support or Task

        // mapping
        // Done -> Done
        // WOC -> Done
        // Ready For Rlease -> Done
        // update source jira
        let targetJiraStatus = new JiraStatus();

        targetJiraStatus.jiraClient = this.targetJira;
        targetJiraStatus.workflow = this.mapping[type];

        await targetJiraStatus.updateTransition(issueKeyOrId, finalStatus);
    }
}
/*
var syncTicketStatus = new SyncTicketStatus(JSON.parse(localStorage.getItem('config')).target);
syncTicketStatus.mapping = {
    Support: [
        "Start Progress",
        "Solution Design",
        "Start Support",
        "Waiting for Reply to Customer",
        "Resolve Issue"
    ],
    Task: [
        'To Do',
        'In Progress',
        'Done'
    ]
};
*/